<?php

namespace addons\mental\controller;

// use think\addons\Controller;

class Index extends Base
{
     protected $noNeedLogin = ['index','customerService','dataBottom','orderqueryimg','getPrivacy','getUserAgreement','getConsultNotice','getRuzhuDes'];

    public function index()
    {
        //精选阅读
        $articleModel = new \app\admin\model\article\Article();
        $articl_list = $articleModel->with(['articlecategory'])->where(['article.is_del'=>0,'is_hot'=>1])->select();
        //用户收藏状态
        if ($articl_list){
            foreach ($articl_list as $key=>&$value){
                //用户登录
                if ($this->auth->id){
                    $like = $articleModel->where(['user_id'=>$this->auth->id,'main_id'=>$value['id']])->find();
                    $value['like'] = $like?1:0;
                }else{
                    $value['like'] = 0;
                }
            }
        }
        //精选视频
        $videoModel = new \app\admin\model\video\Video();
        $video_list = $videoModel->with(['videocategory'])->where(['video.is_del'=>0,'is_hot'=>1])->select();
        if ($video_list){
            foreach ($video_list as $key=>&$value){
                if ($this->auth->id){
                    $like = $videoModel->where(['user_id'=>$this->auth->id,'main_id'=>$value['id']])->find();
                    $value['like'] = $like?1:0;
                }else{
                    $value['like'] = 0;
                }

            }
        }

        //精选咨询师
        $xlzxModel = new \app\admin\model\xlzxinfo\Xlzxinfo();
        $xlzx_list = $xlzxModel->where(['status'=>1,'is_hot'=>1])->order('weigh','desc')->select();
        $this->success("成功",compact('articl_list','video_list','xlzx_list'));
    }


    public function customerService()
    {
        $arr = [
                'wxNum'=>config('site.wxNum'),
                'wxEr'=>config('site.wxEr'),
            ];
        return json_encode($arr);
    }
    
    
    /**
     * 底部公众号小程序数据(addons/mental/index/dataBottom)
     */
    public function dataBottom(){
        
        
        $arr = [
            'dataBottom1'=>config('site.dataBottom1'),
            'dataBottom3'=>config('site.dataBottom3'),
            'dataBottomImage1'=>config('site.dataBottomImage1'),
            'dataBottomImage2'=>config('site.dataBottomImage2'),
            'dataBottom4'=>config('site.dataBottom4'),
            'gongzhonghaoName'=>config('site.gongzhonghaoName'),
            ];
        $this->success('成功',$arr);
    }
    
     /**
     * 订单查询指引图(addons/mental/index/orderqueryimg)
     */
    public function orderqueryimg()
    {
        // orderChackImage
        // 
        
        $url = config('site.orderChackImage');
        $this->success('成功',$url);
    }
    
    
    /**
     * 隐私协议(addons/mental/index/getPrivacy)
     */
    public function getPrivacy()
    {
        $this->success('成功',config('site.privacy'));
    }
    
    /**
     * 用户协议(addons/mental/index/getUserAgreement)
     */
    public function getUserAgreement()
    {
        $this->success('成功',config('site.userAgreement'));
    }

    /**
     * 咨询须知(addons/mental/index/getConsultNotice)
     */
    public function getConsultNotice()
    {
        $this->success('成功',config('site.consult_notice'));
    }
    /**
     * 入驻说明
     */
    public function getRuzhuDes()
    {
        $this->success('成功',config('site.ruzhu_des'));
    }


}
